import { ElMessage, ElNotification } from 'element-plus'

const MESSAGE = 'message'
const NOTIFICATION = 'notification'

//定义Mess类
class Mess {
  #message

  //初始化catch
  constructor(type) {
    this.#message = type === MESSAGE ? ElMessage : ElNotification
  }

  //显示
  show(options) {
    this.#message(options)
  }

  //关闭所有消息
  closeAll() {
    this.#message.closeAll()
  }

  //成功
  success(value) {
    this.#message.success(value)
  }

  //报警
  warning(value) {
    this.#message.warning(value)
  }

  //信息
  info(value) {
    this.#message.info(value)
  }

  //错误
  error(value) {
    this.#message.error(value)
  }
}

//定义ElMessage
const messageMess = new Mess(MESSAGE)
//定义ElNotification
const notificationMess = new Mess(NOTIFICATION)

export { messageMess, notificationMess }
